<!--读者主页-->
<html>
<head>
    <meta charset="utf-8">
    <title>${readercard.name}的主页</title>
    <style>
        body{
            background-color: rgb(240,242,245);
        }
    </style>
</head>


<body>
<!--成功展示-->
    <div hidden class="alert alert-success alert-dismissable">
        <button type="button" class="close" data-dismiss="alert"
                aria-hidden="true">
            &times;
        </button>
            ${succ}
    </div>
<!--//错误展示-->
    <div hidden class="alert alert-danger alert-dismissable">
        <button type="button" class="close" data-dismiss="alert"
                aria-hidden="true">
            &times;
        </button>
            ${error}
    </div>

<div class="col-xs-5 col-md-offset-3">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">
                我的信息
            </h3>
        </div>
        <div class="panel-body">
            <table class="table table-hover">
                <tr>
                    <th width="20%">读者证号</th>
                    <td id="reader_id"></td>
                </tr>
                <tr>
                    <th>姓名</th>
                    <td id="name"></td>
                </tr>
                <tr>
                    <th>性别</th>
                    <td id="sex"></td>
                </tr>
                <tr>
                    <th>生日</th>
                    <td id="birth"></td>
                </tr>
                <tr>
                    <th>地址</th>
                    <td id="address"></td>
                </tr>
                <tr>
                    <th>电话</th>
                    <td id="telcode"></td>
                </tr>
                </tbody>
            </table>
        </div>
        <a id="update_reader" class="btn btn-success btn-sm" role="button">修改</a>
    </div>
</div>


</body>
<script>
    $(function () {
        // var parameter = getParameter("reader_id");
        var parameter = $.cookie("reader_id");
        $.ajax({
            type:"post",
            dataType:"json",
            data:{"reader_id":parameter},
            url:"user/selectReader",
            success:function (data) {
                //alert(data.reader_id)
                $("#reader_id").html(data.reader_id);
                $("#name").html(data.name);
                $("#sex").html(data.sex);
                $("#birth").html(format(data.birth));
                $("#address").html(data.address);
                $("#telcode").html(data.telcode);
                $("#update_reader").click(function () {
                    // location.href="reader_info_edit.html?reader_id="+data.reader_id;
                    $("#middle").load("reader_info_edit.html");
                })

            }
        })
    })

    function format(object) {
        var year = new Date(object).getFullYear(); //获取完整的年份(4位,1970-????)
        var month = new Date(object).getMonth() + 1; //获取当前月份(0-11,0代表1月)
        var day = new Date(object).getDate(); //获取当前日(1-31)
        if (month < 10) {
            month = "0" + month;
        }
        if (day < 10) {
            day = "0" + day;
        }
        var dateString =  year + "-" + month + "-" + day;
        return dateString;

    }

</script>
</html>
